VACUUM (3D) - taking advantage of field period symmetry for nonaxisymmetric vacuum calculations#306
VACUUM (3D) - taking advantage of field period symmetry for nonaxisymmetric vacuum calculations#306jhalpern30 wants to merge 29 commits into
Conversation
…s now points per field period
…tead of the mode numbers, required for mode family stellarator logic
…ernel with observed speedup/memory reduction and no change in solution!
… into feature/3Dvac_nfp
…ponse calculations
… instead of complicated if statements
…for Solovev ideal 3D benchmark
…x numbers, removing stale code, integrating it into vacuum code and elsewhere in perturbed equilibrium
…forward forward and inverse transforms
…to the non-block circulant form for nfp = 1 where that method is worse
…to the non-block circulant form for nfp = 1 where that method is worse
… into feature/3Dvac_nfp
… into feature/3Dvac_nfp
… into feature/3Dvac_nfp
BenchmarksNumerical ImprovementI created a test where I initialize a boundary at some specified resolution and nfp and run both the nfp optimized code and with the same boundary but with nfp = 1 after I mirror the boundary such that it goes through the dense solve of the code. There is clearly a great speedup/memory reduction that increases with nfp, showing I am taking advantage of the symmetry. Note that these do have AdaptiveArrayPooling integrated but were tested with 3D GPEC IntegrationFor an integration test with 3D GPEC + n_stride capabilities, I ran the full workflow for Junyoung's sample NFP = 3 equilibrium with: and and This result indicates that the most unstable mode lives in the n = [2, 5] decoupled family, and we can recapture it to within numerical error while only running with these modes. When running with the other n = [1, 4] family, we capture a more stable mode instead |
|
@claude review |
ReviewThis is a large PR (710+/1582-, 18 files) that bundles two things: (1) the NFP block-circulant fast path for 3D vacuum response, and (2) a broad refactor of the Fourier-transform plumbing from grouped real/imag (cos/sin) matrices to a single complex basis, which ripples through Bugs / correctness
Physics / numerics
Process
Minor
|
|
Regression results for solovev_n1, solovev_multi_n, diiid_n1 |
|
@jy021125 wanted to make sure you are tagged on this one - this should enable the n_stride = nfp implementation we discussed over email + some runtime improvements to speed and memory. I have pushed the corresponding changes needed in the python to the open PR on your github, so if you want to test this, it should work with the python on the Let me know if you find any bugs testing this out! |
Summary
This PR prepares the Julia vacuum module for 3D stellarator use by adding an NFP-exploiting fast path for 3D vacuum response that preserves the full-torus answer at lower cost. It takes advantage of the block-circulant structure of the boundary integral operator matrix when there is an
nfp= # of field periods symmetry of the boundary. This has computational advantages that scale likenfp^3for compute andnfpfor storage without losing ANY information in the solve.In other words - there is still toroidal mode decoupling in stellarator geometry, but instead of no toroidal modes being coupled, only modes with identical
k = n mod nfpare coupled, and these modes are deemed a "mode family". The code can be solved for each of these mode families individually, similar to DCON. The structure I have implemented allows for both 1) all mode families to be solved in a single call (but solved independently to still take advantage of the speedup) and 2) for a single mode family, which is even faster.The 3D VACUUM code can now accept inputs for a list of toroidal modes, not necessarily equally spaced, along with the boundary over only one field period to better interface with the 3D plasma response.
Note that unlike #190, there is no loss of accuracy when implementing this improvement since the toroidal modes are completely decoupled.
Other required code changes
The only real numerical differences are in the 3D components of the vacuum code. However, cosmetic changes were necessary/came up elsewhere:
VacuumInputinput arrays endpoint exclusive (helps for when I have to mirror the field periods to construct the full boundary)VacuumInputaccept a vector of modes versus themlow, mhighetc. And propagating this to the fourier coefficientscompute_fourier_coefficientsreturn the complex basis, rather than the sin and cos terms. This led to a major rework throughout the rest of the code that cleaned up a lot. This probably should have been a separate PR, but I didn't know I would have to do this ahead of time and its integrated in what I was doing here already. I removed the benchmarking script which at this point is very stale and not worth keeping up to dateStill need to do in this PR
grri/grrematrix construction for perturbed equilibria are not integrated or tested in 3D yet